####################################
## Data Analysis for:
## Learning as a Peer Assessor: 
## Evaluating Peer-Assessment Strategies
## Christopher Culver
## Last Updated: 7 Jul 2022
####################################

install.packages("tidyverse")
install.packages("gplots")
install.packages("sclaes")

library(tidyverse)
library(readxl)
library(gplots)
library(scales)


#setwd("C:/Users/Christopher.Culver/OneDrive - afacademy.af.edu/MTCC/Peer Assessment/Data")
setwd("C:/Users/chris/Google Drive/Peer Assessment")

rm(list = ls())

Data <- read_excel("Peer Assessment Complete Data Set.xlsx")
attach(Data)

Data$group <- factor(Data$group,levels = c(1,2), 
                        labels = c("Feedback", "No Feedback"))

grouplabels <- c("Feedback Group Mean","No Feedback Group Mean")
par(mar=c(5, 6, 4, 2) + 0.1)
plotmeans(end_value_learn ~ group, data = Data, connect = FALSE, 
          ylim = c(0,3.5), xlab ="", 
          ylab = '"The peer assessment activity was valuable to my learning process"\n 0 = Strongly Disagree   2 = Neutral   4 = Strongly Agree', 
          legends = grouplabels,
          main = 'Figure 1\nStudents Perceived Value of Peer-Assessment\nSurvey Data')


plotmeans(improve ~ group, data = Data, connect = FALSE,
          yaxt="none", xlab="", ylab="Average improvement in graded work after peer-assessment",ylim = c(0,.2),
          main = "Figure 2\nStudent improvement",
          legends = grouplabels)
axis(2, at=seq(0,.2,.05), lab=percent(seq(0,.2,.05)))

grouplabelssub <- c("1A: anonymous","1B: known","2A: rank order","2B: numeric")
plotmeans(end_value_learn ~ subgroup, data = Data, connect = FALSE, 
          ylim = c(0,3.5), 
          ylab = '"The peer assessment activity was valuable to my learning process"\n 0 = Strongly Disagree   2 = Neutral   4 = Strongly Agree', 
          xlab = "Subgroups: 1A/1B - Received Feedback,   2A/2B - No Feedback Groups",
          legends = grouplabelssub,
          main = "Figure 3\nStudents Perceived Value of Peer-Assessment\nMean Values Across Groups")


plotmeans(improve ~ subgroup, data = Data, connect = FALSE,
          yaxt="none", ylab="Average improvement in graded work after peer-assessment",ylim = c(-0.05,.2),
          legends = grouplabelssub, xlab="Subgroups: 1A/1B - Received Feedback,   2A/2B - No Feedback Groups",
          main = "Figure 4\nStudent improvement")
axis(2, at=seq(0,.2,.05), lab=percent(seq(0,.2,.05)))


#### For poster ####
n1 <- sapply(split(end_value_learn, subgroup), length)
levels.subgroup <- levels(subgroup)

plotmeans(end_value_learn ~ subgroup, data = Data, connect = FALSE, 
          ylim = c(0,3.5), ylab="Mean of 5 point Likert scale", xlab="", yaxt="none", xaxt="n",
          n.label = FALSE, main = "Students' Perceived\nValue of Peer-Assessment")
axis(2, cex.axis=1.1, at=seq(0,3.5,.5), lab=formatC(seq(0,3.5,.5),format="f",digits=1))
axis(1, cex.axis=2, at=c(1,2,3,4), lab=paste0(c("1A","1B","2A","2B")))
axis(1, at=c(1,2,3,4), cex.axis=1.5, pos=0.3,col = NA, lab=paste0("N=", n1))

n2 <- sapply(split(improve, subgroup), length)

plotmeans(improve ~ subgroup, data = Data, connect = FALSE,
          yaxt="none", xaxt="n", xlab="", ylab="Mean of Change in Graded Work", ylim = c(-0.05,.2),
          n.label = FALSE, main = "Student improvement")
axis(2, cex.axis=1.1, at=seq(0,.2,.05), lab=percent(seq(0,.2,.05)))
axis(1, cex.axis=2, at=c(1,2,3,4), lab=paste0(c("1A","1B","2A","2B")))
axis(1, at=c(1,2,3,4), cex.axis=1.5, pos=-0.03,col = NA, lab=paste0("N=", n2))


#####

plotmeans(end_imp_final ~ group, data = Data, connect = FALSE,
          xlab="", ylim = c(0,3.5),
          ylab = '"The peer assessment on the final project was a valuable tool for improving my final product"\n 0 = Strongly Disagree   2 = Neutral   4 = Strongly Agree', 
          legends = grouplabels,
          main = "Figure 5\nStudents Perceived Value of Peer-Assessment on Final Project\nSurvey Data")

plotmeans(final_paper ~ group, data = Data, connect = FALSE,
          yaxt="none", xlab="", ylab="Average Instructor-Awarded Grade on Final Project",ylim = c(0.7,1),
          legends = grouplabels,
          main = "Figure 6\nFinal Project Performance")
axis(2, at=seq(0.7,1,.05), lab=percent(seq(0.7,1,.05)))


plotmeans(end_imp_final ~ subgroup, data = Data, connect = FALSE,
          xlab="Subgroups: 1A/1B - Received Feedback,   2A/2B - No Feedback Groups", ylim = c(0,3.5),
          ylab = '"The peer assessment activity was valuable to my learning process"\n 0 = Strongly Disagree   2 = Neutral   4 = Strongly Agree', 
          main = "Figure 7\nStudents Perceived Value of Peer-Assessment on Final Project\nSurvey Data")


plotmeans(final_paper ~ subgroup, data = Data, connect = FALSE,
          yaxt="none", ylab="Average Instructor-Awarded Grade on Final Project",ylim = c(0.7,1),
          xlab="Subgroups: 1A/1B - Received Feedback,   2A/2B - No Feedback Groups",
          legends = grouplabelssub,
          main = "Figure 8\nFinal Project Performance")
axis(2, at=seq(0.7,1,.05), lab=percent(seq(0.7,1,.05)))


plotmeans(end_value_learn ~ assessing_help, data = Data, connect = FALSE, 
          ylim = c(0,3), xlab ="Students metioned value of readinging peers' work in comments", ylab = "Mean of 5 point Likert scale", 
          main = "Figure 10\nStudents' Perceived\nValue of Peer-Assessment")
